<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>订单评价</title>
<%@ include file="/WEB-INF/component/commonCSS.jsp" %> 
<style type="text/css">
      .text-left{
      color:#949494;
      }
    </style>
</head>
<body class="skin-blue-light sidebar-mini fixed skin-blue-light-frame">
  <section class="content">
      <table class="infoBox">
      <tr>
        <td width="100px" class="infoBoxleft">
        <p style="color:#fff;font-size:20px;text-align:center;font-weight:600">订单信息</p>
        </td>
        <td>
        	<form role="form" class="form-horizontal" action="${ctx }/purOrderInfo/saveReviews.html"  method="post">
                <div class="box-body" style="background:url('${ctx }/lib/img/infobg.png') no-repeat bottom right;">
                    <div class="form-group form-group-xs"  style="margin-top:5px;">
                    <label class="col-sm-2 text-right">订单包号：</label>
                        <div class="col-sm-3 text-left" id="orderPackId">
                            ${info.orderPackId }                           
                        </div>
                        <label class="col-sm-2 text-right">随货单号：</label>
                        <div class="col-sm-3 text-left" id="withOrderId">
                           ${info.withOrderId }
                        </div>
                    </div>
                    
                    <div class="form-group form-group-xs" style="margin-top:-10px">
                        <label class="col-sm-2 text-right">出库时间：</label>
                        <div class="col-sm-3 text-left" id="delDatetime">
                           ${info.delDatetime }
                        </div>
                        <label class="col-sm-2 text-right">物流详情：</label>
                        <div class="col-sm-3 text-left" id="interflowDetail">
                           ${info.interflowDetail }
                        </div>
                    </div>
                    
                   <div class="form-group form-group-xs" style="margin-top:-10px;margin-bottom:-10px;">
                        <label class="col-sm-2 text-right">评分：</label>                        
                        <div class="col-sm-3 text-left">
                           <input class="form-control" id="gradeScore" name="gradeScore" value="${form.gradeScore }" placeholder="0-10分" type="text" maxlength="10">
                        </div>
                        <label class="col-sm-2 text-right">评分备注：</label>
                        <div class="col-sm-3 text-left">
                           <input class="form-control" id="gradeRemark" name="gradeRemark" value="${form.gradeRemark }" placeholder="评分备注" type="text" maxlength="10">                        
                       </div>
                </div>
                </div>
             </form>
        </td>
      </tr>
      </table>
      
      <!-- <div class=" box box-success">
            <div class="box-header"></div>

            <form role="form" class="form-horizontal" action="${ctx }/purOrderInfo/saveReviews.html"  method="post">
                <div class="box-body">               
                <div class="form-group form-group-xs">
                        <label class="col-sm-2 text-right">订单包号：</label>
                        <div class="col-sm-4 text-left" id="orderPackId">
                            ${info.orderPackId }
                           
                        </div>
                        <label class="col-sm-2 text-right">随货单号：</label>
                        <div class="col-sm-4 text-left" id="withOrderId">
                        ${info.withOrderId }
                        </div>
                   </div>
                    
                <div class="form-group form-group-xs">
                        <label class="col-sm-2 text-right">出库时间：</label>
                        <div class="col-sm-4 text-left" id="delDatetime">
                        ${info.delDatetime }
                        </div>
                        <label class="col-sm-2 text-right">物流详情：</label>
                        <div class="col-sm-4 text-left" id="interflowDetail">
                        ${info.interflowDetail }
                        </div>
                   </div>
                <div class="form-group form-group-xs">
                        <label class="col-sm-2 text-right">评分：</label>
                        
                        <div class="col-sm-4 text-left">
                        <input class="form-control" id="gradeScore" name="gradeScore" value="${form.gradeScore }" placeholder="0-10分" type="text" maxlength="10">
                        </div>
                        <label class="col-sm-2 text-right">评分备注：</label>
                        <div class="col-sm-4 text-left">
                        <input class="form-control" id="gradeRemark" name="gradeRemark" value="${form.gradeRemark }" placeholder="评分备注" type="text" maxlength="10">
                        
                        </div>
                   </div>
              </div>
              
            </form>
        </div>-->
        
        <table class="jqgrid" id="gridlist"></table>
        <div id="gridpage"></div>
        <div class=" box box-warning bottongroup">
        	<label id="batchModifyData" onclick="modifyReturnPlan()" class="btn btn-default btn-sm">评 价</label>
        </div>
        
    </section>
    <%@ include file="/WEB-INF/component/commonJS.jsp" %> 
	<script type="text/javascript">
	 $(function () {

        	
        	$("#gridlist").jqGrid({
                url: "${ctx}/purOrderInfo/getHospOderOldDetail.html?orderPackId=${param.orderPackId}",
                mtype: "POST",
                datatype: "json",
                autowidth: true,
                shrinkToFit: false,
                height: 270,
                colNames: ['药品ID','订单编号','订单包号','采购价','采购数量','采购金额','配送数量','配送金额','药品编码', '通用名', '剂型', '规格','转换系数','单位','材质','生产企业','采购限价','归档原因','所属项目'],
                colModel: [
					{ name: 'drugId', width:80, hidden:true,align:"center", sortable:false  },  
					{ name: 'orderCode', hidden:true, width: 80, align: "center", sortable:false },
					{ name: 'orderPackId',  hidden:true, width: 80, align: "center", sortable:false },
					{ name: 'proPrice',  width: 80, align: "right" , sortable:false,
                 	   formatter:function(cellvalue, options, row){
                           return formatAmount(cellvalue, options, row);
                       }},
					{ name: 'proCount',  width: 80, align: "center" , sortable:false },
					{ name: 'buyPrice',  width: 80, align: "right", sortable:false,
                 	   formatter:function(cellvalue, options, row){
                           return formatAmount(cellvalue, options, row);
                       }},
					{ name: 'delCount',  width: 80, align: "center", sortable:false },
					{ name: 'delPrice',  width: 80, align: "right", sortable:false,
                 	   formatter:function(cellvalue, options, row){
                            return formatAmount(cellvalue, options, row);
                        }},
					{ name: 'drugCode',  width: 100, align: "center", sortable:false,
						formatter:function(cellvalue, options, row) {
							return "<a href=\"javascript:$.HN.dialog.opendialog('"+row.drugId+"','药品详情','${ctx}/stdDrug/drugInfoDetail.html?drugId="+row.drugId+"','800px','400px',function operResult(val){return operResult;})\">"+cellvalue+"</a>"
                    	}},
					{ name: 'drugName',  width: 140,align:"left", sortable:false },
                    { name: 'formName',  width: 80 , align: "center", sortable:false },
                    { name: 'specName',  width: 80, align: "left", sortable:false  },
                    { name: 'factor',  width: 80, align: "center", sortable:false },
                    { name: 'unit',  width: 40, align: "center", sortable:false },
                    { name: 'materialName',  width: 80, align: "center", sortable:false },
                    { name: 'compName',  width: 180, align: "center" ,  sortable:false,
						 formatter:function(cellvalue, options,row) {
							 return "<a href=\"javascript:$.HN.dialog.opendialog('"+row.compId+"','"+cellvalue+"','${ctx}/stdCompinfo/toStdCompinfoDetail.html?compId="+row.compId+"','800px','400px',function operResult(val){return operResult;})\">"+cellvalue+"</a>";
			     		} },
                    { name: 'proPriceLimit',  width: 80, align: "right", sortable:false},
                    { name: 'archiveType',  width: 130, hidden:true,align: "left", sortable:false},
                    { name: 'projName', hidden:true, width: 130, align: "center", sortable:false }
                ],
                rowNum: 20,
                rowList: [10, 20, 50, 100],
                rownumbers: true,
                pager: "#gridpage",
                //multiselect: true, 
                viewrecords: true,
                caption: "配送企业：${delCompName}",
                jsonReader: {
                    repeatitems: false,
                    id: "ids"
                }
            });
            $("#gridlist").jqGrid('navGrid', '#gridpage', { add: false, edit: false, del: false, search: false, refresh: false });
            $(window).trigger("resize");
        });
   function back(){
   	//window.location.href="${pageContext.request.contextPath}/stdDrug/list.html";
   	history.back();
   }
 //保存
 		function saveStep() {
    			 $("#form").ajaxSubmit({
        			dataType : "json",
        			timeout: 10000,
        			 success : function(result, statusText) {
        				if (result.success) {
        					 $.HN.message.alert("保存成功！", "消息", "success");
        				 } else {
        					$.HN.message.alert(result.msg || "", "消息", "error");
        				}
        			} 
        		}); 
    		}
    	
	function modifyReturnPlan() {
				
		 /*var rowIds = $("#gridlist").jqGrid("getGridParam", "selarrrow") || [];
		
		var list = [];
		for (var i=0; i<rowIds.length; i++) {
			rowId = rowIds[i];
			var rowdata = $("#gridlist").jqGrid('getRowData', rowId);
			list.push({"orderPackId":rowdata.orderPackId});
		}   */
		//alert("${info.orderPackId }");
		var score = ['0','1','2','3','4','5','6','7','8','9','10'];
		var gradeScore = $("#gradeScore").val();
		if(gradeScore==null||gradeScore==""){
			$.HN.message.alert("请填写评分！", "消息", "success");
			return;
		}
		var flag = false;
		for(var i = 0;i<score.length;i++){
			if(gradeScore==score[i]){
				flag = true;
				break;
			}
		}
		
		
		if(!flag){
			$.HN.message.alert("评分只能是0-10的整数！", "消息", "success");
			return;
		}
		
		var rowIds = $("#gridlist").jqGrid("getGridParam", "selarrrow") || [];
		$.HN.message.confirm("确定评价吗？", '', '').on(function (e) {
            if (e) {
		$.post("${ctx}/purOrderInfo/saveReviews.html", {
			"orderPackId" : "${info.orderPackId }","gradeScore":$("#gradeScore").val(),"gradeRemark":$("#gradeRemark").val(),"interflowId":"${info.orderPackId }"
		}, function(result) {
			if (result.success) {
				$.HN.message.alert("操作成功！", "消息", "success");
				var dialog = top.dialog.get(window);
	        	 dialog.close("success"); // 关闭（隐藏）对话框
	        	 dialog.remove();				 // 主动销毁对话框
			} else {
				$.HN.message.alert(result.msg, "消息", "error");
			}
		}, "json").error(function(err) {
		});
            }
		});
	}
   
	</script>
</body>
</html>